package com.odm.communitymanage.ui.DoorSafe

import android.os.Bundle
import androidx.lifecycle.Observer
import com.blankj.utilcode.util.GsonUtils
import com.blankj.utilcode.util.LogUtils
import com.jeremyliao.liveeventbus.LiveEventBus
import com.odm.communitymanage.R
import com.odm.communitymanage.base.BaseMVVMFragment
import kotlinx.android.synthetic.main.fragment_visitor_card.*

/**
 * @description: 来访者通信证页面
 * @author: ODM
 * @date: 2020/4/12
 */
class VisitorCardFragment : BaseMVVMFragment() {

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        registerLiveEvent()
        super.onActivityCreated(savedInstanceState)
    }

    override fun initViewModelObserve() {

    }

    override fun initViews() {

    }

    override fun getLayoutId(): Int {
        return R.layout.fragment_visitor_card
    }
    
    fun registerLiveEvent(){
        LiveEventBus.get("fake_visitor_card" , InviteVisitorFragment.PostInvitorInfo::class.java)
            .observeSticky(this  , object : Observer<InviteVisitorFragment.PostInvitorInfo>{
                override fun onChanged(t: InviteVisitorFragment.PostInvitorInfo?) {
                    tvTenantName_VisitorCard?.text = t?.visited_name
                    tvAddress_VisitorCard?.text = t?.address
                    ivVisitorCardCode_detail.setImageResource(R.mipmap.fake_visitor_code)
                }
            })
    }
}